<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta property="wb:webmaster" content="5e6fd87ff3b3e6a8" />
    <title>rongself</title>
    <script src="Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="Scripts/json2.min.js" type="text/javascript"></script>
    <script src=" http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=3078170559" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
        $(function(){
            WB2.anyWhere(function(W){
                W.widget.connectButton({
                    id:'wb_connect',
                    type: '1,2',
                    callback : {
                        login:function(o){
                            alert(JSON.stringify(o));
                        },
                        logout:function(){
                            alert('logout');
                        }
                    }
                });
            });
            $('#login_btn').click(function(){
                WB2.login(function(){
                    alert('login success!!');
                });
            });
            $('#logout_btn').click(function(){
                WB2.logout(function(){
                    alert('logout success!!');
                });
            });
            $('#read_friends').click(function(){
                if(WB2.checkLogin()){
                     WB2.anyWhere(function(W){
                        var currentUid;
                        W.parseCMD(
                            "/account/get_uid.json",
                            function(sResult, bStatus){
                                currentUid = sResult.uid;
                                 W.parseCMD(
                                    "/friendships/friends.json",
                                    function(sResult, bStatus){
                                        //alert(JSON.stringify(sResult.user)); 
                                        $(sResult.users).each(function(){
                                            var face_url = $(this)[0].profile_image_url;
                                            var name = $(this)[0].name;
                                            var url = $(this)[0].profile_url;
                                            $('#content').append('<img src="'+face_url+'"/><a href="http://weibo.com/'+url+'">'+name+'</a><br/>');   
                                        });
                                    },
                                    {
                                        uid:currentUid,
                                        count:'200'
                                    },
                                    {
                                       method: 'get' 
                                    }
                                );
                            },
                            {
                                appkey:'3078170559'
                            },
                            {
                                method: 'get'
                            }
                        );
                            //alert(currentUid);
                       
                    });
                }else{
                    alert('please login!');
                }
               
            });
        });
    </script>
</head>
<body>
    <div id="wb_connect"></div>
    <a id="login_btn" href="javascript:void(0);">Weibo login</a>
    <br/>
    <a id="logout_btn" href="javascript:void(0);">Weibo logout</a>
    <br/>
    <a id="read_friends" href="javascript:void(0);">Get my friends</a>
    <div id="content"></div>
</body>
</html>